rsync server daemon on Mac OS X with launchctl
(Update: Added the --no-detach option to the rsync command. Newer MacOS versions wouldn't start the daemon without it. With the added argument, it now works again in Sierra.)
There are many web pages describing how to enable the rsync daemon on Mac OS X using launchd/launchctl mechanism. But I had to use a different (and simpler) plist file in LaunchDaemons to make it work across reboots on Lion (10.7.4).
(I started by following this guide , and this very similar one. And I also read this and this. In the end, what helped me getting the plist file right was this thread. Particularly this post: "For one you have both a Program and a ProgramArguments key, when you should have only one or the other (you use Program if there is just one element to the command, or ProgramArguments if there are multiple." And this one.)
This is the .plist file I used in /Library/LaunchDaemons/org.samba.rsync.plist :
<?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> <plist version="1.0"> <dict> <key>Disabled</key> <false/> <key>Label</key> <string>org.samba.rsync</string> <key>ProgramArguments</key> <array> <string>/usr/bin/rsync</string> <string>--daemon</string> <string>--no-detach</string> </array> <key>RunAtLoad</key> <true/> <key>KeepAlive</key> <dict> <key>SuccessfulExit</key> <false/> </dict> </dict> </plist>
This is an example /etc/rsyncd.conf file:
secrets file = /etc/rsyncd.secrets hosts allow = 192.168.1.0/24 10.0.0.1 *.cust.isp.tld uid = nobody gid = nobody list = yes read only = yes [shared] path = /Users/Shared comment = Users-Shared uid = someuser gid = admin auth users = user_in_secrets
The file /etc/rsyncd.secrets looks like:
some_rsync_user:password other_user:other_password
To install it:
sudo -s chown root:wheel /etc/rsyncd.* chmod 644 /etc/rsyncd.conf chmod 600 /etc/rsyncd.secrets launchctl load /Library/LaunchDaemons/org.samba.rsync.plist launchctl start org.samba.rsync ## (this last command is probably unneeded)
To check if it is installed and running:
launchctl list | grep rsync 808 - 0x7fddb4806c10.anonymous.rsync - 0 org.samba.rsync ps ax | grep [r]sync 808 ?? Ss 0:00.00 /usr/bin/rsync --daemon rsync --stats someuser@localhost::
To remove it:
sudo launchctl unload /Library/LaunchDaemons/org.samba.rsync.plist sudo killall rsync
For logging transfers, add
log file = /var/log/rsyncd.log transfer logging = yes
to /etc/rsyncd.conf. And to have the log rotated, create a file like /etc/newsyslog.d/rsyncd.conf and add
# logfilename [owner:group] mode count size when flags [/pid_file] [sig_num] /var/log/rsyncd.log 644 5 5000 * J
7 Comments:
Very helpful, thanks. Small error as well:
launchctl start org.samba.rsync.plist
should be:
launchctl start org.samba.rsync
Also: the rsyncd.secrets - file is set to /etc/rsync/rsyncd.secrets in the rsyncd.conf, but later and in the text you refer to /etc/rsyncd.secrets .
Thank you, otherwise everything worked like a charm!
Thanks for writing it out so clearly!
Your setup, with modificatons, perfectly until I updated to Maverick.
No amount of tweaking will make it run now.
Ideas?
@MenacingM, @Daniel: Thanks! Corrected.
@Øystein Nytrø: I just installed it on Mavericks, and it seems to run fine. It was a fresh install of OS X, not an upgrade. So I'm afraid I don't know what went wrong with your setup.
i just installed on sierra, seems to work great. backing up data from a qnap ts-421u to a drobo. All is well, thanks for the information
Thanks for taking the time to do this write up.
I just wrote a small 'one button' GUI app which starts the rsync daemon for you:
http://bonhardcomputing.com/rsync-server/
But am wondering if people might want a more 'fully featured' GUI app, with accounts, access controls, etc???
Am also working on a client which 'looks like FTP, goes like rsync'.
Hello,
I'm so happy to find subjects about RSYNC.
Very good post.
I try to configure RSYNC to synchronize files between my Xserve and a Synology NAS.
I have see your App "rsync server GUI" on your blog http://bonhardcomputing.com/rsync-server/ ; very good... but why not use the fully standard configuration (/etc/rsync.conf + secrets).
If you can add options for experts i suppose you app can be the top !
I use Mac OS X for simply GUI... redo configuration like BSD is not cool on Mac.
You can enhancing your application in this way... i take !
Best regards,
TB
http://myuxvintagecomputing.com
Post a Comment
<< Home